/*************************************************
Author: byron
Date: 12/11/2012
Description:
Notes: 
*************************************************/

#ifndef __CWorldBossData_h__
#define __CWorldBossData_h__

#include "commclass.h"
#include "../common/CRankArray.h"

class MsgWorldBossAtkRank;

class CWorldBossRole
{
public:
    CWorldBossRole()
    {
        Clear();
    }

    void Clear()
    {
        _chDieTimes = 0;
        _chMerlinTimes = 0;
        _iEndTime = 0;
        _iActBeginTime = 0;
        _iAtkValue = 0;
    }

    virtual ~CWorldBossRole()
    {
    }

    char GetDieTimes() const {return _chDieTimes;}
    char GetMerlinTimes() const {return _chMerlinTimes;}
    int GetAtkValue() const {return _iAtkValue;}
    int GetEndTime() const {return _iEndTime;}
    int GetActBeginTime() const {return _iActBeginTime;}

    void SetDieTimes(char chDieTimes){_chDieTimes = chDieTimes;}
    void SetMerlinTimes(char chMerlinTimes){_chMerlinTimes = chMerlinTimes;}
    void SetAtkValue(int iNewAtk){_iAtkValue = iNewAtk;}
    void SetEndTime(int iEndTime){_iEndTime = iEndTime;}
    void SetActBeginTime(int iBeginTime){_iActBeginTime = iBeginTime;}

    void AddAtkValue(int iChgAtk)
    {
        _iAtkValue = CT_MAX(_iAtkValue + iChgAtk, 0);
    }

private:
    char        _chDieTimes;    //死亡次数
    char        _chMerlinTimes; //梅林祝福购买次数
    int         _iEndTime;      //失效时刻
    int         _iActBeginTime; //活动开启时间
    int         _iAtkValue;     //攻击怪物伤害总量
};

class CWorldBossAtkUnit
{
public:
    CWorldBossAtkUnit()
    {
        Clear();
    }

    void Clear()
    {
        _iAtkValue = 0;
        _iAcademy = 0;
        _uiGID = 0;
        _sRoleName.Set("");
    }

    virtual ~CWorldBossAtkUnit()
    {
    }

    int GetAtkValue() const {return _iAtkValue;}
    int GetAcademy() const {return _iAcademy;}
    unsigned int GetGID() const {return _uiGID;}
    char* GetRoleName() const {return _sRoleName.Get();}

    void SetAtkValue(int iAtkValue){_iAtkValue = iAtkValue;}
    void SetAcademy(int iVal){_iAcademy = iVal;}
    void SetGID(unsigned int uiGID){_uiGID = uiGID;}
    void SetRoleName(const char* pszName){_sRoleName.Set(pszName);}
    void GetAtkRankUnit(MsgWorldBossAtkRank& stAtkRankUnit);

private:
    int                 _iAtkValue;     //攻击伤害
    int                 _iAcademy;      //所在学院
    unsigned int        _uiGID;         //角色GID
    CTSizeString<ROLENAME_LEN>  _sRoleName; //角色名
};

class CWorldBossMonster
{
public:
    enum WORLD_BOSS_MONSTER_TAG
    {
        WB_MONSTER_ATK_RANK_COUNT = 100,     //怪物受击伤害榜单元上限
        WB_MONSTER_RANK_SHOW_COUNT = 10,    //受击伤害榜前端显示数量
    };

    CWorldBossMonster()
    {
        Clear();
    }

    void Clear()
    {
        _iEndTime = 0;
        _iAtkValue = 0;
        _iMonsterHP = 0;
        _iMonsterHPMax = 0;
        _iInspireTrigger = 0;
        _iLastNotify = 0;
        _iWorldLevel = 0;
        _iMonsterBornTime = 0;
        _uiLastNotifyGID = 0;
        _uiMonsterGroupID = 0;
        _uiMapID = 0;
        _uiKillerGID = 0;
        _stAtkRank.Clear();
    }

    virtual ~CWorldBossMonster()
    {
    }

    unsigned int GetMapID() const {return _uiMapID;}
    int GetEndTime() const {return _iEndTime;}
    int GetAtkValue() const {return _iAtkValue;}
    int GetMonsterHP() const {return _iMonsterHP;}
    int GetMonsterHPMax() const {return _iMonsterHPMax;}
    int GetLastNotify() const {return _iLastNotify;}
    int GetWorldLevel() const {return _iWorldLevel;}
    int GetMonsterBornTime() const {return _iMonsterBornTime;}
    unsigned int GetLastNotifyGID() const {return _uiLastNotifyGID;}
    unsigned int GetKillerGID() const {return _uiKillerGID;}
    int GetInspireTrigger() const {return _iInspireTrigger;}
    int GetMonsterGroupID() const {return _uiMonsterGroupID;}

    void SetMapID(unsigned int uiMapID){_uiMapID = uiMapID;}
    void SetEndTime(int iEndTime){_iEndTime = iEndTime;}
    void SetAtkValue(int iAtkValue){_iAtkValue = iAtkValue;}
    void SetMonsterHP(int iMonsterHP){_iMonsterHP = iMonsterHP;}
    void SetMonsterHPMax(int iMonsterHPMax){_iMonsterHPMax = iMonsterHPMax;}
    void SetLastNotify(int iLastNotify){_iLastNotify = iLastNotify;}
    void SetWorldLevel(int iWorldLevel){_iWorldLevel = iWorldLevel;}
    void SetMonsterBornTime(int iBornTime){_iMonsterBornTime = iBornTime;}
    void SetLastNotifyGID(unsigned int uiLastNotifyGID)
    {
        _uiLastNotifyGID = uiLastNotifyGID;
    }
    void SetKillerGID(unsigned int uiVal)
    {
        _uiKillerGID = uiVal;
    }
    void SetInspireTrigger(int iInspireTrigger)
    {
        _iInspireTrigger = iInspireTrigger;
    }
    void SetMonsterGroupID(unsigned int uiMonsterGroupID)
    {
        _uiMonsterGroupID = uiMonsterGroupID;
    }

    void AddAtkValue(int iChgAtk)
    {
        _iAtkValue = CT_MAX(_iAtkValue + iChgAtk, 0);
    }

    int UpdateRank(CWorldBossAtkUnit& stNewUnit, int& iOld, int& iNew)
    {
        return _stAtkRank.Update(stNewUnit, iOld, iNew);
    }

    int GetRankSize() const {return _stAtkRank.Size();}

    CWorldBossAtkUnit& GetRankUnit(int iIndex)
    {
        return _stAtkRank[iIndex];
    }

    int GetRankRoleOrder(unsigned int uiGID);

private:
    int             _iEndTime;
    int             _iAtkValue;
    int             _iMonsterHP;
    int             _iMonsterHPMax;
    int             _iInspireTrigger;
    int             _iLastNotify;
    int             _iWorldLevel;
    int             _iMonsterBornTime;
    unsigned int    _uiLastNotifyGID;
    unsigned int    _uiMonsterGroupID;
    unsigned int    _uiMapID;
    unsigned int    _uiKillerGID;

    CRankArray<CWorldBossAtkUnit, WB_MONSTER_ATK_RANK_COUNT> _stAtkRank;
};

#endif //__CWorldBossData_h__


